var utils = require("../../../utils/util.js");
var app = getApp();
Page({
  data: {
    dominameImg: utils.dominameImg,
    orderInfo:{
      create_time:'',
      pay_time:'',
      closing_time:''
    }
  },
  onLoad:function(options){
    let that = this;
    wx.showLoading();
    wx.request({
      url: utils.dominame+'/api/zbds/shop/order_detail', //仅为示例，并非真实的接口地址
      data: {
        token: app.globalData.token,
        order_id: options.orderId
      },
      method: "GET",
      header: {
        "Content-Type": "application/x-www-form-urlencoded"  //post
      },
      complete: function (res) {
        wx.hideLoading();
      },
      success: function (res) {
        console.log(res);
        if (res.data.code == 0) {
          that.setData({
            orderInfo:res.data.data
          });
        }
      }
    })
  },
  goPay:function(e){
    wx.navigateTo({
      url: "../../payChoose/payChoose?actual=" + e.currentTarget.dataset.actual +'&order_id='+e.currentTarget.id,
    })
  },
  makeSure:function(e){
    var that = this;
    wx.showModal({
      title: '提示',
      content: '是否确认收货？',
      success: function (res) {
        if (res.confirm) {
          wx.request({
            url: utils.dominame + '/api/v1/order/confirmReceipt',
            data: {
              token: app.globalData.token,
              order_id: e.currentTarget.id,
              channel: 2
            },
            header: { "Content-Type": "application/x-www-form-urlencoded" },
            method: 'GET',
            dataType: 'json',
            responseType: 'text',
            success: function (res) {
              console.log(res);
              if (res.data.code == 0) {
                wx.showToast({
                  title: '确认成功',
                  icon: 'none',
                  success:function(){
                    wx.navigateBack({
                      delta: 1
                    })
                  }
                });
              }
            },
            fail: function (res) { },
            complete: function (res) {
              // wx.hideLoading();
            },
          })
        }
      }
    })
  },
})